home *** CD-ROM | disk | FTP | other *** search
/ Chip 1996 September / CHIP 1996 szeptember (CD07).zip / CHIP_CD07.ISO / sac / pack / vbdlh02.exe / VBDE_SRC.LZH / VBDECMD.BAS < prev    next >
BASIC Source File  |  1996-03-08  |  21KB  |  487 lines

  1. '=================================================
  2. 'Call VB Common Dialog
  3. 'VBDeCMD.Bas
  4. 'Original: Niiyama(HEROPA) SGV00153@niftyserve.or.jp
  5. 'English : Hitoshi Ozawa   h_ozawa@bekkoame.or.jp
  6. '=================================================
  7. Option Explicit
  8. Dim mstrCmdialogFileName    As String   'file name used by common dialog
  9. Dim mlngErrorCode           As Long     'error code used by common dialog
  10.  
  11. Type OPENFILENAME   'OPENFILENAME structure definition
  12.     lStructSize         As Long     'lStructSize size
  13.     hwndOwner           As Integer  'window associated with dialog box
  14.     hInstance           As Integer  'data block including dialog box template specified by lpTemplateName member
  15.     lpstrFilter         As Long     'filter. NULL appended
  16.     lpstrCustomFilter   As Long     'user defined filter string
  17.     nMaxCustFilter      As Long     'buffer size classified by lpstrCustomFilter member
  18.     nFilterIndex        As Long     'index to buffer pointed to by lpstrFilter member
  19.     lpstrFile           As Long     'pointer to buffer containing file name
  20.     nMaxFile            As Long     'buffer size pointed to by lpstrFile member
  21.     lpstrFileTitle      As Long     'pointer to buffer containing title of selected file
  22.     nMaxFileTitle       As Long     'maximum length of text string to be copied to lpstrFileTitle buffer
  23.     lpstrInitialDir     As Long     'pointer to text string specifying first file directory
  24.     lpstrTitle          As Long     'pointer to name of dialog box title bar text string
  25.     flags               As Long     'dialog box initialization flag
  26.     nFileOffset         As Integer  'offset from beginning of path to position of file name specified by lpstrFile buffer
  27.     nFileExtension      As Integer  'offset from beginning of path to position of extension specified by lpstrFile buffer
  28.     lpstrDefExt         As Long     'pointer to default extension buffer
  29.     lCustData           As Long     'application definition data sent by hook function specified by lpfnHook member to a system
  30.     lpfnHook            As Long     'pointer to hook function that processes messages sent to dialog box
  31.     lpTemplateName      As Long     'pointer to text string ending with NULL
  32. End Type
  33.  
  34. 'Error code returned by executing common dialog box procedure
  35. Declare Function CommDlgExtendedError Lib "COMMDLG.DLL" () As Long
  36. 'open file open file selection system dialog box
  37. Declare Function GetOpenFileName Lib "COMMDLG.DLL" (pOPENFILENAME As OPENFILENAME) As Integer
  38. 'open file save file selection system dialog box
  39. Declare Function GetSaveFileName Lib "COMMDLG.DLL" (pOPENFILENAME As OPENFILENAME) As Integer
  40. '    Global Const OFN_READONLY = &H1
  41. '    Global Const OFN_OVERWRITEPROMPT = &H2
  42.     Global Const OFN_HIDEREADONLY = &H4
  43. '    Global Const OFN_NOCHANGEDIR = &H8
  44. '    Global Const OFN_SHOWHELP = &H10
  45. '    Global Const OFN_ENABLEHOOK = &H20
  46. '    Global Const OFN_ENABLETEMPLATE = &H40
  47. '    Global Const OFN_ENABLETEMPLATEHANDLE = &H80
  48. '    Global Const OFN_NOVALIDATE = &H100
  49.     Global Const OFN_ALLOWMULTISELECT = &H200
  50. '    Global Const OFN_EXTENSIONDIFFERENT = &H400
  51.     Global Const OFN_PATHMUSTEXIST = &H800
  52.     Global Const OFN_FILEMUSTEXIST = &H1000
  53. '    Global Const OFN_CREATEPROMPT = &H2000
  54. '    Global Const OFN_SHAREAWARE = &H4000
  55.     Global Const OFN_NOREADONLYRETURN = &H8000
  56. '    Global Const OFN_NOTESTFILECREATE = &H10000
  57.  
  58. '    Global Const OFN_SHAREFALLTHROUGH = 2
  59. '    Global Const OFN_SHARENOWARN = 1
  60. '    Global Const OFN_SHAREWARN = 0
  61.  
  62. 'release object and handle if global memory object is not locked
  63. Declare Function GlobalFree Lib "Kernel" (ByVal hglb As Integer) As Integer
  64. 'return pointer to global memory object
  65. Declare Function GlobalLock Lib "Kernel" (ByVal hglb As Integer) As Long
  66. 'allocate specified bytes of global heap
  67. Declare Function GlobalAlloc Lib "Kernel" (ByVal fuAlloc As Integer, ByVal cbAlloc As Long) As Integer
  68. 'release specified global memory object lock
  69. Declare Function GlobalUnLock Lib "Kernel" (ByVal hglb As Integer) As Integer
  70.     Global Const GMEM_MOVEABLE = &H2
  71.     Global Const GMEM_ZEROINIT = &H40
  72.     Global Const GHND = (GMEM_MOVEABLE Or GMEM_ZEROINIT)
  73. 'copy byte data from one buffer to another
  74. Declare Sub hmemcpy Lib "Kernel" (hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)
  75.  
  76. Function CMDError (lngErrCode As Long) As String
  77.     
  78.     Select Case lngErrCode&
  79.     Case 32765
  80.         CMDError$ = "#" & LTrim$(Str$(lngErrCode&)) & ",  " & "Unable to initialize common dialog controls.(Not enough memory)"
  81.     Case 32761
  82.         CMDError$ = "#" & LTrim$(Str$(lngErrCode&)) & ",  " & "Unrecognizable text string."
  83.     Case 32760
  84.         CMDError$ = "#" & LTrim$(Str$(lngErrCode&)) & ",  " & "Unrecognizable resource."
  85.     Case 32759
  86.         CMDError$ = "#" & LTrim$(Str$(lngErrCode&)) & ",  " & "Unable to lock specified resource."
  87.     Case 32758
  88.         CMDError$ = "#" & LTrim$(Str$(lngErrCode&)) & ",  " & "Unable to allocate memory to structure."
  89.     Case 32757
  90.         CMDError$ = "#" & LTrim$(Str$(lngErrCode&)) & ",  " & "Unable to memory associated with handle."
  91.     Case 32755
  92.         CMDError$ = "#" & LTrim$(Str$(lngErrCode&)) & ",  " & "<Cancel> button was chosen."
  93.     Case 32752
  94.         CMDError$ = "#" & LTrim$(Str$(lngErrCode&)) & ",  " & "Unable to allocate memory to FileName and Filter properties."
  95.     Case 32751
  96.         CMDError$ = "#" & LTrim$(Str$(lngErrCode&)) & ",  " & "Error calling WinHelp."
  97.     Case 28671
  98.         CMDError$ = "#" & LTrim$(Str$(lngErrCode&)) & ",  " & "PD_RETURNDEFAULT set in PRINTDLG data structure, but AhDevMode or hDevNames field set to non-zero value."
  99.     Case 28670
  100.         CMDError$ = "#" & LTrim$(Str$(lngErrCode&)) & ",  " & "Failed to read necessary resources."
  101.     Case 28669
  102.         CMDError$ = "#" & LTrim$(Str$(lngErrCode&)) & ",  " & "Unable to recognize setting in [DEVICES] section in WIN.INI file."
  103.     Case 28668
  104.         CMDError$ = "#" & LTrim$(Str$(lngErrCode&)) & ",  " & "PD_RETURNDEFAULT set in PRINTDLG data structure, but AhDevMode or hDevNames field set to non-zero value."
  105.     Case 28667
  106.         CMDError$ = "#" & LTrim$(Str$(lngErrCode&)) & ",  " & "Failed to access printer driver specified by PRINTDLG."
  107.     Case 28666
  108.         CMDError$ = "#" & LTrim$(Str$(lngErrCode&)) & ",  " & "Failed to initialize DEVMODE structure in printer driver."
  109.     Case 28665
  110.         CMDError$ = "#" & LTrim$(Str$(lngErrCode&)) & ",  " & "Unable to initialize PRINTDLG function."
  111.     Case 28664
  112.         CMDError$ = "#" & LTrim$(Str$(lngErrCode&)) & ",  " & "Printer driver not found."
  113.     Case 28663
  114.         CMDError$ = "#" & LTrim$(Str$(lngErrCode&)) & ",  " & "Default printer not defined."
  115.     Case 28662
  116.         CMDError$ = "#" & LTrim$(Str$(lngErrCode&)) & ",  " & "DEVMODE and DEVNAMES data points to 2 different printers."
  117.     Case 28661
  118.         CMDError$ = "#" & LTrim$(Str$(lngErrCode&)) & ",  " & "Error creating content text information in PRINTDLG."
  119.     Case 28660
  120.         CMDError$ = "#" & LTrim$(Str$(lngErrCode&)) & ",  " & "Missing printer entry in [DEVICES] section in WIN.INI file."
  121.     Case 24574
  122.         CMDError$ = "#" & LTrim$(Str$(lngErrCode&)) & ",  " & "Font not found. Set on of CF_BOTH, CF_PRINTERFONTS, or CF_SCREENFONTS before trying to display Font Section dialog box."
  123.     Case 20478
  124.         CMDError$ = "#" & LTrim$(Str$(lngErrCode&)) & ",  " & "Not enough memory. Unable to display items in list box."
  125.     Case 20477
  126.         CMDError$ = "#" & LTrim$(Str$(lngErrCode&)) & ",  " & "Illegal file name."
  127.     Case 20476
  128.         CMDError$ = "#" & LTrim$(Str$(lngErrCode&)) & ",  " & "Buffer specified by lpstrFile member too small. Only first character of file name set to FileName propery."
  129.     Case Else
  130.         CMDError$ = "Unknow COMMDIALOG Error:  #" & Str$(lngErrCode&)
  131.     End Select
  132. End Function
  133.  
  134. Function CMDFileOpen (DstForm As Form, lngFError&, strFilter$, strIDir$, strTitle$, intIndex%, lngFlags&) As Integer
  135.  
  136.     CMDFileOpen% = 0
  137.     lngFError& = 0
  138.  
  139.     Dim tagOPENFILENAME As OPENFILENAME
  140.     Dim lngAddress      As Long
  141.  
  142.     Dim szFile          As String * 1024
  143.     Dim szFilter        As String
  144.     Dim szInitialDir    As String
  145.     Dim szTitle         As String
  146.     Dim wSize           As Long
  147.     Dim MemHandle       As Integer
  148.     Dim intReturnCode   As Integer
  149.  
  150.     szFilter$ = strFilter$
  151.     szInitialDir$ = strIDir$
  152.     szTitle$ = strTitle$
  153.  
  154.     wSize& = Len(szFile$) + Len(szFilter$) + Len(szInitialDir$) + Len(szTitle$)
  155.     
  156.     MemHandle% = GlobalAlloc(GHND, wSize&)
  157.  
  158.     If MemHandle% = 0 Then
  159.         CMDFileOpen% = 1
  160.         Exit Function
  161.     End If
  162.     ' ----------------------------------------------------
  163.  
  164.     
  165.     ' ----------------------------------------------------
  166.     ' Lock global memory, then copy it to local memory
  167.     ' ----------------------------------------------------
  168.     lngAddress& = GlobalLock(MemHandle%)
  169.     If lngAddress& = 0 Then
  170.         CMDFileOpen% = 2
  171.         Exit Function
  172.     Else
  173.         Call hmemcpy(ByVal lngAddress, ByVal (szFile$ + szFilter$ + szInitialDir$ + szTitle$), wSize)
  174.     End If
  175.     ' ----------------------------------------------------
  176.     
  177.     tagOPENFILENAME.lStructSize = Len(tagOPENFILENAME)
  178.     tagOPENFILENAME.hwndOwner = DstForm.hWnd
  179.     tagOPENFILENAME.flags = lngFlags&
  180.     tagOPENFILENAME.nFilterIndex = intIndex%
  181.     tagOPENFILENAME.lpstrFile = lngAddress&
  182.     tagOPENFILENAME.nMaxFile = Len(szFile$)
  183.     tagOPENFILENAME.lpstrFilter = lngAddress& + Len(szFile$)
  184.     tagOPENFILENAME.lpstrInitialDir = tagOPENFILENAME.lpstrFilter + Len(szFilter$)
  185.     tagOPENFILENAME.lpstrTitle = tagOPENFILENAME.lpstrInitialDir + Len(szInitialDir$)
  186.  
  187.     intReturnCode% = GetOpenFileName(tagOPENFILENAME)
  188.     lngFError& = CommDlgExtendedError()
  189.     
  190.     If intReturnCode% = 0 Then
  191.         CMDFileOpen% = 3
  192.     Else
  193.         Call hmemcpy(ByVal szFile$, ByVal lngAddress&, Len(szFile$))
  194.     End If
  195.     
  196.     intReturnCode% = GlobalUnLock(MemHandle%)    'Free memory
  197.     intReturnCode% = GlobalFree(MemHandle%)
  198.  
  199.     If intReturnCode% <> 0 Then Exit Function
  200.  
  201.     mstrCmdialogFileName$ = Left$(szFile$, InStr(szFile$, Chr$(0)) - 1)
  202.  
  203. End Function
  204.  
  205. Function CMDFileSave (DstForm As Form, lngFError&, strFilter$, strIDir$, strFileMask$, intIndex%, strTitle$, lngFlags&) As Integer
  206.     
  207.     'Initialize variables
  208.     CMDFileSave% = 0
  209.     lngFError& = 0
  210.  
  211.     ' This is similar to GetOpenFileName
  212.     Dim tagOPENFILENAME As OPENFILENAME
  213.     Dim lngAddress As Long
  214.  
  215.     Dim szFile As String
  216.     Dim szFilter As String
  217.     Dim szInitialDir As String
  218.     Dim szTitle As String
  219.     Dim wSize As Long
  220.     Dim MemHandle As Integer
  221.     Dim intReturnCode As Integer
  222.  
  223.     szFile$ = strFileMask$ + String$(256 - Len(strFileMask$), 0)
  224.     szFilter$ = strFilter$
  225.     szInitialDir$ = strIDir$
  226.     szTitle$ = strTitle$
  227.     wSize& = Len(szFile$) + Len(szFilter$) + Len(szInitialDir$) + Len(szTitle$)
  228.  
  229.     MemHandle% = GlobalAlloc(GHND, wSize&)
  230.  
  231.     If MemHandle% = 0 Then
  232.         CMDFileSave% = 1
  233.         Exit Function
  234.     End If
  235.  
  236.     lngAddress& = GlobalLock(MemHandle%)
  237.     If lngAddress& = 0 Then
  238.         CMDFileSave% = 2
  239.         Exit Function
  240.     Else
  241.         Call hmemcpy(ByVal lngAddress, ByVal (szFile$ + szFilter$ + szInitialDir$ + szTitle$), wSize)
  242.     End If
  243.  
  244.     tagOPENFILENAME.lStructSize = Len(tagOPENFILENAME)
  245.     tagOPENFILENAME.hwndOwner = DstForm.hWnd
  246.     tagOPENFILENAME.flags = lngFlags&
  247.     tagOPENFILENAME.nFilterIndex = intIndex%
  248.     tagOPENFILENAME.lpstrFile = lngAddress&
  249.     tagOPENFILENAME.nMaxFile = Len(szFile$)
  250.     tagOPENFILENAME.lpstrFilter = lngAddress& + Len(szFile$)
  251.     tagOPENFILENAME.lpstrInitialDir = tagOPENFILENAME.lpstrFilter + Len(szFilter$)
  252.     tagOPENFILENAME.lpstrTitle = tagOPENFILENAME.lpstrInitialDir + Len(szInitialDir$)
  253.  
  254.     intReturnCode% = GetSaveFileName(tagOPENFILENAME)
  255.     lngFError& = CommDlgExtendedError()
  256.  
  257.     If intReturnCode% = 0 Then
  258.         CMDFileSave% = 3
  259.         Exit Function
  260.     Else
  261.         Call hmemcpy(ByVal szFile$, ByVal lngAddress&, Len(szFile$))
  262.     End If
  263.  
  264.     intReturnCode% = GlobalUnLock(MemHandle%)    'Free Memory
  265.     intReturnCode% = GlobalFree(MemHandle%)
  266.  
  267.     mstrCmdialogFileName$ = Left$(szFile$, InStr(szFile$, Chr$(0)) - 1)
  268.     
  269.     'Debug.Print "Path = " & LeftB$(mstrCmdialogFileName$, tagOPENFILENAME.nFileOffset)
  270.     'Debug.Print "Filename = " & RightB$(mstrCmdialogFileName$, Len(mstrCmdialogFileName$) - tagOPENFILENAME.nFileOffset)
  271.     'Debug.Print "Extension = " & RightB$(mstrCmdialogFileName$, Len(mstrCmdialogFileName$) - tagOPENFILENAME.nFileExtension)
  272. End Function
  273.  
  274. Function CMDFilesOpen (DstForm As Form, lngFError&, strFilter$, strIDir$, strTitle$, intIndex%, lngFlags&) As Integer
  275.  
  276.     CMDFilesOpen% = 0
  277.     lngFError& = 0
  278.  
  279.     Dim tagOPENFILENAME As OPENFILENAME
  280.     Dim lngAddress      As Long
  281.  
  282.     Dim szFile          As String * 1024
  283.     Dim szFilter        As String
  284.     Dim szInitialDir    As String
  285.     Dim szTitle         As String
  286.     Dim wSize           As Long
  287.     Dim MemHandle       As Integer
  288.     Dim intReturnCode   As Integer
  289.  
  290.     szFilter$ = strFilter$
  291.     szInitialDir$ = strIDir$
  292.     szTitle$ = strTitle$
  293.  
  294.     wSize& = Len(szFile$) + Len(szFilter$) + Len(szInitialDir$) + Len(szTitle$)
  295.     
  296.     MemHandle% = GlobalAlloc(GHND, wSize&)
  297.  
  298.     If MemHandle% = 0 Then
  299.         CMDFilesOpen% = 1
  300.         Exit Function
  301.     End If
  302.     ' ----------------------------------------------------
  303.  
  304.     
  305.     ' ----------------------------------------------------
  306.     ' Lock global memory, then copy it to local memory
  307.     ' ----------------------------------------------------
  308.     lngAddress& = GlobalLock(MemHandle%)
  309.     If lngAddress& = 0 Then
  310.         CMDFilesOpen% = 2
  311.         Exit Function
  312.     Else
  313.         Call hmemcpy(ByVal lngAddress, ByVal (szFile$ + szFilter$ + szInitialDir$ + szTitle$), wSize)
  314.     End If
  315.     ' ----------------------------------------------------
  316.     
  317.     tagOPENFILENAME.lStructSize = Len(tagOPENFILENAME)
  318.     tagOPENFILENAME.hwndOwner = DstForm.hWnd
  319.     tagOPENFILENAME.flags = lngFlags&
  320.     tagOPENFILENAME.nFilterIndex = intIndex%
  321.     tagOPENFILENAME.lpstrFile = lngAddress&
  322.     tagOPENFILENAME.nMaxFile = Len(szFile$)
  323.     tagOPENFILENAME.lpstrFilter = lngAddress& + Len(szFile$)
  324.     tagOPENFILENAME.lpstrInitialDir = tagOPENFILENAME.lpstrFilter + Len(szFilter$)
  325.     tagOPENFILENAME.lpstrTitle = tagOPENFILENAME.lpstrInitialDir + Len(szInitialDir$)
  326.  
  327.     intReturnCode% = GetOpenFileName(tagOPENFILENAME)
  328.     lngFError& = CommDlgExtendedError()
  329.     
  330.     If intReturnCode% = 0 Then
  331.         CMDFilesOpen% = 3
  332.     Else
  333.         Call hmemcpy(ByVal szFile$, ByVal lngAddress&, Len(szFile$))
  334.     End If
  335.     
  336.     intReturnCode% = GlobalUnLock(MemHandle%)    'Free memory
  337.     intReturnCode% = GlobalFree(MemHandle%)
  338.  
  339.     If intReturnCode% <> 0 Then Exit Function
  340.  
  341.     'mstrCmdialogFileName$ = LeftB$(szFile$, InStrB(szFile$, Chr$(0)) - 1)
  342.  
  343.     Dim strPath     As String
  344.     Dim strFiles    As String
  345.     'Append text string to UNLHA.DLL command line.
  346.     'Append "\" to directory name and insert space to file names.
  347.  
  348.     strPath$ = Trim$(Left$(Left$(szFile$, InStr(szFile$, Chr$(0)) - 1), tagOPENFILENAME.nFileOffset))
  349.     If Right$(strPath$, 1) <> "\" Then strPath$ = strPath$ & "\"
  350.  
  351.     strFiles$ = Right$(Left$(szFile$, InStr(szFile$, Chr$(0)) - 1), Len(Left$(szFile$, InStr(szFile$, Chr$(0)) - 1)) - tagOPENFILENAME.nFileOffset)
  352.     If Trim$(strFiles$) = "" Then
  353.         mstrCmdialogFileName$ = ""
  354.     Else
  355.         mstrCmdialogFileName$ = strPath$ & " " & strFiles$
  356.     End If
  357.     'Debug.Print "You selected = " & LeftB$(szFile$, InStrB(szFile$, Chr$(0)) - 1)
  358.     'Debug.Print "Path = " & LeftB$(LeftB$(szFile$, InStrB(szFile$, Chr$(0)) - 1), tagOPENFILENAME.nFileOffset)
  359.     'Debug.Print "Filename = " & RightB$(LeftB$(szFile$, InStrB(szFile$, Chr$(0)) - 1), Len(LeftB$(szFile$, InStrB(szFile$, Chr$(0)) - 1)) - tagOPENFILENAME.nFileOffset)
  360.     'Debug.Print "Extension = " & RightB$(mstrCmdialogFileName$, Len(mstrCmdialogFileName$) - tagOPENFILENAME.nFileExtension)
  361. End Function
  362.  
  363. Function Open_Files (DstForm As Form) As String
  364.     ' ----------------------------------------------------
  365.     ' intResponce% = 0 means everything OK
  366.     ' intResponce% = 1 means couldn't allocate global memory
  367.     ' intResponce% = 2 means couldn't lock global memory
  368.     ' intResponce% = 3 means had error returned from common dialog
  369.     ' lngFError& tells you WHAT error if intResponce% = 3
  370.     ' ----------------------------------------------------
  371.     Dim strFilter   As String
  372.     Dim intIndex    As Integer
  373.     Dim lngFlags    As Long
  374.     Dim strIDir     As String
  375.     Dim strTitle    As String
  376.     Dim intResponce As Integer
  377.     Dim lngFError   As Long
  378.     Dim strMsg      As String
  379.     Dim intType     As Integer
  380.  
  381.     mstrCmdialogFileName$ = ""
  382.     strFilter$ = "All Files (*.*)" & Chr$(0) & "*.*" & Chr$(0)
  383.     strFilter$ = strFilter$ & Chr$(0)
  384.     intIndex% = 1
  385.     lngFlags& = OFN_ALLOWMULTISELECT Or OFN_FILEMUSTEXIST Or OFN_HIDEREADONLY Or OFN_PATHMUSTEXIST
  386.     
  387.     strIDir$ = CurDir$ & Chr$(0)
  388.     strTitle$ = "File Selection" & Chr$(0)
  389.     
  390.     intResponce% = CMDFilesOpen%(DstForm, lngFError&, strFilter$, strIDir$, strTitle$, intIndex%, lngFlags&)
  391.     ' ----------------------------------------------------
  392.  
  393.     If lngFError& <> 0 Then
  394.         strMsg$ = CMDError$(mlngErrorCode&)
  395.         intType% = MB_OK Or MB_ICONEXCLAMATION Or MB_APPLMODAL
  396.         MsgBox strMsg$, intType%, APP_CAPTION
  397.     Else
  398.         Open_Files$ = mstrCmdialogFileName$
  399.     End If
  400.  
  401. End Function
  402.  
  403. Function Open_Lzh_File (DstForm As Form) As String
  404.     ' ----------------------------------------------------
  405.     ' intResponce% = 0 means everything OK
  406.     ' intResponce% = 1 means couldn't allocate global memory
  407.     ' intResponce% = 2 means couldn't lock global memory
  408.     ' intResponce% = 3 means had error returned from common dialog
  409.     ' lngFError& tells you WHAT error if intResponce% = 3
  410.     ' ----------------------------------------------------
  411.     Dim strFilter   As String
  412.     Dim intIndex    As Integer
  413.     Dim lngFlags    As Long
  414.     Dim strIDir     As String
  415.     Dim strTitle    As String
  416.     Dim intResponce As Integer
  417.     Dim lngFError   As Long
  418.     Dim strMsg      As String
  419.     Dim intType     As Integer
  420.  
  421.     mstrCmdialogFileName$ = ""
  422.     strFilter$ = "Lzh Files (*.LZH)" & Chr$(0) & "*.lzh" & Chr$(0)
  423.     strFilter$ = strFilter$ & "SFX Files (*.EXE)" & Chr$(0) & "*.exe" & Chr$(0)
  424.     strFilter$ = strFilter$ & "All Files (*.*)" & Chr$(0) & "*.*" & Chr$(0)
  425.     strFilter$ = strFilter$ & Chr$(0)
  426.     intIndex% = 1
  427.     lngFlags& = OFN_FILEMUSTEXIST Or OFN_HIDEREADONLY Or OFN_PATHMUSTEXIST
  428.     
  429.     strIDir$ = CurDir$ & Chr$(0)
  430.     strTitle$ = "File Selection" & Chr$(0)
  431.     
  432.     intResponce% = CMDFileOpen%(DstForm, lngFError&, strFilter$, strIDir$, strTitle$, intIndex%, lngFlags&)
  433.     ' ----------------------------------------------------
  434.  
  435.     If lngFError& <> 0 Then
  436.         strMsg$ = CMDError$(mlngErrorCode&)
  437.         intType% = MB_OK Or MB_ICONEXCLAMATION Or MB_APPLMODAL
  438.         MsgBox strMsg$, intType%, APP_CAPTION
  439.     Else
  440.         Open_Lzh_File$ = mstrCmdialogFileName$
  441.     End If
  442. End Function
  443.  
  444. Function Save_Lzh_File (DstForm As Form) As String
  445.     ' ----------------------------------------------------
  446.     ' intResponce% = 0 means everything OK
  447.     ' intResponce% = 1 means couldn't allocate global memory
  448.     ' intResponce% = 2 means couldn't lock global memory
  449.     ' intResponce% = 3 means had error returned from common dialog
  450.     ' lngFError& tells you WHAT error if intResponce% = 3
  451.     ' ----------------------------------------------------
  452.     Dim strFilter   As String
  453.     Dim strIDir     As String
  454.     Dim strFileMask As String
  455.     Dim strTitle    As String
  456.     Dim intIndex    As Integer
  457.     Dim lngFlags    As Long
  458.     Dim intResponce As Integer
  459.     Dim lngFError   As Long
  460.     Dim strMsg      As String
  461.     Dim intType     As Integer
  462.  
  463.     mstrCmdialogFileName$ = ""
  464.     strFilter$ = "Lzh Files (*.LZH)" & Chr$(0) & "*.lzh" & Chr$(0) & Chr$(0)
  465.     strIDir$ = CurDir$ + Chr$(0)
  466.     If gstrLzhFile$ = "" Then
  467.         strFileMask$ = "Untitled.LZH"
  468.     Else
  469.         strFileMask$ = gstrLzhFile$
  470.     End If
  471.     strTitle$ = "Save File" + Chr$(0)
  472.     intIndex% = 1
  473.     lngFlags& = OFN_HIDEREADONLY Or OFN_PATHMUSTEXIST Or OFN_NOREADONLYRETURN
  474.     
  475.     intResponce% = CMDFileSave%(DstForm, lngFError&, strFilter$, strIDir$, strFileMask$, intIndex%, strTitle$, lngFlags&)
  476.     ' ----------------------------------------------------
  477.  
  478.     If lngFError& <> 0 Then
  479.         strMsg$ = CMDError$(mlngErrorCode&)
  480.         intType% = MB_OK Or MB_ICONEXCLAMATION Or MB_APPLMODAL
  481.         MsgBox strMsg$, intType%, APP_CAPTION
  482.     Else
  483.         Save_Lzh_File$ = mstrCmdialogFileName$
  484.     End If
  485. End Function
  486.  
  487.